<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu" %>

<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<c:set var="hostName" value='<%=request.getServerName()%>'/>
<style>
.s-key li .inputstyle1{border:1px solid #D8D8D8;float:left;padding:2px 5px;margin:0px 1px}
</style>
<script type="text/javascript" src="/js/pageable.js"></script>

<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<script type="text/javascript">
$().ready( function() {
	$('#form_searchKeyword').keyup(function(){
		$('#keyword').attr('value', $('#form_searchKeyword').attr('value'));
		if($(this).attr('value')!=''){
			hadKeyin=true;
			$('#keyword').attr('class', 'search-page');
		}else{
			hadKeyin=false;
			$('#keyword').attr('class', 'search-dpage');
		}
	});
	$('#form_searchKeyword').change(function(){
		$('#keyword').attr('value', $('#form_searchKeyword').attr('value'));
		if($(this).attr('value')!=''){
			hadKeyin=true;
			$('#keyword').attr('class', 'search-page');
		}else{
			hadKeyin=false;
			$('#keyword').attr('class', 'search-dpage');
		}
	});
	$("#minPrice").numeric({allow:"."});
	$("#maxPrice").numeric({allow:"."});
	$('#startDate').datepicker({
		dateFormat:'yy-mm-dd'
			//,
		//showOn: 'button',
		//buttonImage: '/ecmall/images/calendar.jpg',
		//buttonImageOnly: false
		 });
	$('#endDate').datepicker({
		dateFormat:'yy-mm-dd'
			//,
		//showOn: 'button',
		//buttonImage: '/ecmall/images/calendar.jpg',
		//buttonImageOnly: false
		 });
});
</script>
<h2>高级搜索</h2>
<div class="s-key">
<s:form name="formObj" action="search.do" method="get" id="formObj" acceptcharset="UTF-8">
			<s:hidden name="pager.currentPage" id="currentPage"/>
			<s:hidden name="type"/>
			<s:hidden name="display"/>
			<s:hidden name="sortOrder"/>
<input type="hidden" name="z"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<th valign="top">关键字：</th>
		<td valign="top">
			<s:textfield cssClass="txt-gy inputstyle" size="40" id="form_searchKeyword" name="searchKeyword" value=""/>
			<br />
			<label for="search_brief">
				<input type="checkbox" name="searchWithBrief" value="1" />连同&quot;商品特色&quot;一起搜索
			</label>
			(<a class="show-sample" href="javascript:void(0);" onmouseover="$('#sample1').show();" onmouseout="$('#sample1').hide();">范例<div id="sample1"><img src="/images/search/search_adv_1.gif" alt="连同商品特色一起搜索" width="260" height="294" /></div></a>)
			
			<label for="search_description">
				<input type="checkbox" name="searchWithDescription" value="1" />连同&quot;商品描述&quot;一起搜索
			</label>
			(<a class="show-sample" href="javascript:void(0);" onmouseover="$('#sample2').show();" onmouseout="$('#sample2').hide();">范例<div id="sample2"><img src="/images/search/search_adv_2.gif" alt="连同商品描述一起搜索" width="260" height="294" /></div></a>)
		</td>
	</tr>
	<tr>
		<th valign="top">商品类别：</th>
		<td valign="top">
			<select name="categoryL1" onchange="changeCategoryL1();">
				<option value="">全部类别</option>
				<s:iterator var="category" value="categoryL1List">
					<c:if test="${fn:endsWith(hostName, 'yaodian100.com')}">
					<option value="${category.id}">${category.name}</option>
					</c:if>		
					<c:if test="${!fn:endsWith(hostName, 'yaodian100.com')}">
					<c:if test="${category.id!='8'}">
					<option value="${category.id}">${category.name}</option>
					</c:if>
					</c:if>
				</s:iterator>
			</select>
			&nbsp;
			<select name="categoryL2" onchange="changeCategoryL2(this.value)">
				<option value="">全分类</option>
			</select>
			&nbsp;
			<select id="categoryL3" name="categoryL3">
				<option value="">全分类</option>
			</select>
		</td>
	</tr>
	<tr>
		<th valign="top">价格区间：</th>
		<td valign="top">
			<INPUT name="minPrice" id="minPrice" class="inputstyle" size="5" />&nbsp;至&nbsp;<INPUT name="maxPrice" id="maxPrice" class="inputstyle" size="5" />&nbsp;元
		</td>
	</tr>
	<tr>
		<th valign="top">上架日期：</th>
		<td valign="top">
			<input id="startDate" name="startDate" class="inputstyle1" size="10" />
			<img src="/images/calendar.gif" class="datepick-trigger">&nbsp;至&nbsp;
			<input id="endDate" name="endDate" class="inputstyle1" size="10" />
			<img src="/images/calendar.gif" class="datepick-trigger">
		</td>
	</tr>
	<tr>
		<th valign="top">优惠活动：</th>
		<td valign="top">
			<label><input name="flag2" type="checkbox" value="1" id="cam_reduction" /> 立减优惠</label>
			&nbsp;&nbsp;
			<label><input name="flag3" type="checkbox" value="1" id="cam_percentoff" /> 立折优惠</label><br />
			<label><input name="flag4" type="checkbox" value="1" id="cam_precent" /> 送赠品</label>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<label><input name="flag6" type="checkbox" value="1" id="cam_nnm" /> 任选商品</label><br />
			<label><input name="flag7" type="checkbox" value="1" id="cam_addon" /> 加购商品</label>
			&nbsp;&nbsp;
		</td>
	</tr>
	<tr>
		<th valign="top">商品信息：</th>
		<td valign="top">
			<label><input type="checkbox" class="checkbox" id="DAPHNE" value="DAPHNE" name="partner" <c-rt:if test="${pu:contain(param.partner, 'DAPHNE') }">checked="checked"</c-rt:if> /> 门店取货</label>
			&nbsp;&nbsp;
			<label><input name="flag1" type="checkbox" value="1" id="no_include" /> 不包括预购</label>
		</td>
	</tr>
</table>
<script type="text/javascript">

$('#sample1').hide();
$('#sample2').hide();
</script>
<div class="btn"><span><a href="###" onClick="beforeSubmit();" class="btn-mid">搜索</a></span></div>
</s:form>
</div>
</br>
<div id="dialog" title="" class="collection-dailog-ok" style="display: none;"></div>
<script type="text/javascript">
<!--
function beforeSubmit(){
	document.formObj.type.value='search';
	if(document.formObj.categoryL3.value!=''){
		document.formObj.z.value=document.formObj.categoryL3.value;
	}else if(document.formObj.categoryL2.value!=''){
		document.formObj.z.value=document.formObj.categoryL2.value;
	}else if(document.formObj.categoryL1.value!=''){
		document.formObj.z.value=document.formObj.categoryL1.value;
	}
	
	if(document.formObj.searchKeyword.value=="" && document.formObj.z.value==''){
		alertDialog('高级搜索','请输入<em>商品关键字</em>或商品类别！','','400','180');
	}else{
		encodeKeyword2();
	}
	return false;
}

function changeCategoryL1() {
	var form = document.formObj;
	var l1value = form.categoryL1.options[form.categoryL1.selectedIndex].value;
	form.categoryL2.options.length=0;
	try{
		form.categoryL2.add(new Option("全分类", ""), null);
	} catch(e){
		form.categoryL2.add(new Option("全分类", ""));
	}
	<s:iterator var="category" value="categories"><s:if test="%{#category.level eq 1}">
	if(l1value=='${category.parentId}') {
		try{
			form.categoryL2.add(new Option("${category.name}", "${category.id}"), null);
		} catch(e){
			form.categoryL2.add(new Option("${category.name}", "${category.id}"));
		}
	}
</s:if></s:iterator>
}
function changeCategoryL2(categoryId){
	doAR('/ecmall/search/categoryL3.do?z='+categoryId, 'categoryL3');
	
}
changeCategoryL1();

//-->
</script>
